import { EntityModel } from '@midwayjs/orm';
import { BaseEntity } from '@cool-midway/core';
import { Column, OneToMany } from 'typeorm';
import { WeiboBlogPhotoEntity } from './blogPhoto';

/**
 * 商品
 */
@EntityModel('weibo_blog', {
  orderBy: {
    id: 'DESC',
  },
})
export class WeiboBlogEntity extends BaseEntity {
  @Column('varchar', { comment: 'faq | grass | creation' })
  type: string;

  @Column('varchar', { comment: '标题' })
  title: string;

  @Column('text', { comment: '评论说明' })
  comment: string;

  @Column({
    comment: '图片，多个图片按“,”号隔开',
    type: 'text',
    nullable: true,
  })
  pics: string;

  @OneToMany(() => WeiboBlogPhotoEntity, photos => photos.blog)
  photos: WeiboBlogPhotoEntity[];

  @Column({
    comment: '统计评论数',
    nullable: true,
    type: 'int',
    width: 11,
    name: 'count_comment',
  })
  countComment: number;

  @Column({
    comment: '统计阅读数',
    nullable: true,
    type: 'int',
    width: 11,
    name: 'count_view',
  })
  countView: number;

  @Column({
    comment: '统计收藏数',
    nullable: true,
    type: 'int',
    width: 11,
    name: 'count_collect',
  })
  countCollect: number;

  @Column({
    comment: '统计点赞数',
    nullable: true,
    type: 'int',
    width: 11,
    name: 'count_love',
  })
  countLove: number;

  @Column({ comment: '视频', nullable: true, type: 'varchar', name: 'video' })
  video: string;

  @Column({ comment: '音频', nullable: true, type: 'varchar', name: 'audio' })
  audio: string;

  @Column({
    comment: '是否审核:0=待审核,1=已审核,2=已拒绝',
    type: 'tinyint',
    width: 1,
    name: 'is_audit',
    default: 0,
  })
  isAudit: number;

  @Column({ comment: '用户ID', type: 'int', width: 11, name: 'user_id' })
  userId: number;

  @Column({ comment: '标签 tag,tag', nullable: true, type: 'varchar' })
  tags: string;

  @Column({ comment: '商品', nullable: true, type: 'varchar' })
  goods: string;

  @Column({ comment: '活动', nullable: true, type: 'varchar' })
  activity: string;

  @Column({ comment: 'ip地址', name: 'ip_addr', nullable: true, length: 50 })
  ipAddr: string;
  
}
